<!DOCTYPE html>
<html>
<head>
    <title>公告详情</title>
    <link rel="stylesheet" href="/static/assets/css/layui.css" media="all">
</head>
<body>
<form class="layui-form layui-form-pane" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">ID</label>
        <div class="layui-input-inline">
            <input type="text" id="announcementsId" name="announcementsId" lay-verify="required" disabled
                   autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label">标题</label>
        <div class="layui-input-inline">
            <input type="text" id="title" lay-verify="required" disabled autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">失效日期</label>
        <div class="layui-input-inline">
            <input type="text" id="expirydDate" lay-verify="required" disabled autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label">内容</label>
        <div class="layui-input-inline">
            <input type="text" id="content" lay-verify="required" disabled autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">发布日期</label>
        <div class="layui-input-inline">
            <input type="text" id="releaseTime" lay-verify="required" disabled autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label">附件图片</label>
        <div class="layui-input-inline">
            <img style="width: 180px;height: 180px" id="imgs" src=""/>
        </div>
    </div>
    <div class="layui-form-item">

    </div>
</form>
</body>
<script src="/static/assets/layui.js" charset="utf-8"></script>
<script src="/static/assets/jquery.min.js"></script>
<script>
    $(function () {

        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r != null) return unescape(r[2]);
            return null; //返回参数值
        }

        layui.use(['form', 'layer'], function () {
            var form = layui.form,
                layer = layui.layer;
            var announcementsId = getUrlParam('announcementsId')
            $.ajax({
                url: '/announcement/showOne',
                type: 'post',
                dataType: 'json',
                headers: {'Content-Type': 'application/json;charset=utf8'},
                data: JSON.stringify({
                    announcementsId: announcementsId
                }),
                success: function (res) {
                    var Announcement = res.data.Announcement;
                    $("#announcementsId").val(Announcement.announcementsId)
                    $("#title").val(Announcement.title)
                    $("#expirydDate").val(Announcement.expirydDate)
                    $("#content").val(Announcement.content)
                    $("#releaseTime").val(Announcement.releaseTime)
                    $("#imgs").attr("src", Announcement.imgs)
                    layer.msg("拉取信息成功")
                    console.log(res)
                },
                error: function (res) {
                    layer.msg("拉取信息失败")
                }
            })
        })

    })
</script>